﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace ВУИ
{
    public partial class PaspOt : Form
    {
        Form1 Main;
        int id;
        public PaspOt(Form1 main, int Id)
        {
            InitializeComponent();
            Main = main;
            id = Id;
            List<ReportParameter> paramList = new List<ReportParameter>();
             paramList.Add(new ReportParameter("ФИО_Ребенка", Main.lPatient[Main.itnPatietn(id)].This.Surname + " " + Main.lPatient[Main.itnPatietn(id)].This.Name + " " + Main.lPatient[Main.itnPatietn(id)].This.Patronymic));
           
            paramList.Add(new ReportParameter("ФИО_Матери", Main.lPatient[Main.itnPatietn(id)].Mother.Surname + " " + Main.lPatient[Main.itnPatietn(id)].Mother.Name + " " + Main.lPatient[Main.itnPatietn(id)].Mother.Patronymic));
            paramList.Add(new ReportParameter("ФИО_Отца", Main.lPatient[Main.itnPatietn(id)].Father.Surname + " " + Main.lPatient[Main.itnPatietn(id)].Father.Name + " " + Main.lPatient[Main.itnPatietn(id)].Father.Patronymic));
            paramList.Add(new ReportParameter("Дата_Рождения", Main.lPatient[Main.itnPatietn(id)].Date_of_birth.ToShortDateString()));
            paramList.Add(new ReportParameter("Дата_Постановки", Main.lPatient[Main.itnPatietn(id)].Statement_date.ToShortDateString()));
            paramList.Add(new ReportParameter("Адресс",  Main.lPatient[Main.itnPatietn(id)].Adress));
            paramList.Add(new ReportParameter("Телефон",  Main.lPatient[Main.itnPatietn(id)].Tel));
            paramList.Add(new ReportParameter("Масса",  Convert.ToString(Main.lPatient[Main.itnPatietn(id)].Growth)));
            paramList.Add(new ReportParameter("Рост",  Convert.ToString(Main.lPatient[Main.itnPatietn(id)].Weight)));
            paramList.Add(new ReportParameter("Срок_Гестации", Convert.ToString(Main.lPatient[Main.itnPatietn(id)].Gestation)));
            int d = (Main.lPatient[Main.itnPatietn(id)].Statement_date - Main.lPatient[Main.itnPatietn(id)].Date_of_birth).Days;
            int m = 0;
            int y = 0;
            int n = 0;
            while (d > 365)
            {
                d -= 365;
                y++;
            }
            while (d > 30)
            {
                d -= 30;
                m++;
            }
            if ((y < 1) & (m >= 1))
                while (d > 7)
                {
                    d -= 7;
                    n++;
                }
            string s = "";
            if (y > 0)
            {
                s = Convert.ToString(y) + "год(лет) ";
                if (m > 0) s += Convert.ToString(m) + "месяц(а)";
            }
            else
            {
                if (m >= 1)
                {
                    s = Convert.ToString(m) + "месяц(а) ";
                    if (n > 0) s += Convert.ToString(n) + "недели";
                }
                else
                {
                    s = Convert.ToString(d) + "дней(я) ";
                }
            }


            paramList.Add(new ReportParameter("Возрост", Convert.ToString(s))); 
          
            reportViewer1.LocalReport.SetParameters(paramList);
            reportViewer1.RefreshReport();
            
        }

        private void PaspOt_Load(object sender, EventArgs e)
        { 
             
           
           
           
        }

        private void reportViewer1_Load(object sender, EventArgs e)
        {

        }
    }
}
